
function encodeParam4Uri(uri) {
	//alert(uri);
	var uri1 = uri;  
	if (uri.indexOf('?') >=0 ) {
		uri1 = uri.substring(0, uri.indexOf('?'));
		var uri2 = uri.substring(uri.indexOf('?')+1, uri.length);
		var arr = uri2.split('&');
		
		for (var i=0; i<arr.length; i++) {
			var a = arr[i].substring(0, arr[i].indexOf('='));
			var b = arr[i].substring(arr[i].indexOf('=')+1, arr[i].length);
			if (i==0) {
				uri1 += '?';
			}
			uri1 += a + '=' + encodeURIComponent(b);
			
			if ((i+1) < arr.length) {
				uri1 += '&';
			}
		}
	}
	return uri1;
}


var outlet = {
	mdr_load : function(){
		$('table.mdr_rate').find('td.keymaster').each(function(){
			$(this).children('input').on('keyup', function(){
				var td = $(this).closest('td');
				var key_data = td.attr('data-keydata');
				var v = $(this).val();
				$('table.mdr_rate').find('td.keyclient[data-keydata="' + key_data + '"]').children('input').val(v);
			});
		});
		
		$('table.mdr_rate').find('tr.visaplanno').each(function(){
			$(this).children('td').each(function(index, elmt){
				if(index <= 0){
					return;
				}
				
				var sel = $(this).children('select');
				
				sel.data('tdindex', index)
				sel.on('change', function(event){
					var op = sel.children(':selected');
					var td_index = sel.data('tdindex');
					var tr_min = $('table.mdr_rate').find('tr.visaplanno.planmin');
					var tr_max = $('table.mdr_rate').find('tr.visaplanno.planmax');
					
					tr_min.children('td:eq(' + td_index + ')').children('input').val(op.attr('data-min'));
					tr_max.children('td:eq(' + td_index + ')').children('input').val(op.attr('data-max'));
				})
			});
			
		});
		
		
		$('table.mdr_rate').find('tr.amexplanno').each(function(){
			$(this).children('td').each(function(index, elmt){
				if(index <= 0){
					return;
				}
				
				var sel = $(this).children('select');
				
				sel.data('tdindex', index)
				sel.on('change', function(event){
					var op = sel.children(':selected');
					var td_index = sel.data('tdindex');
					var tr_min = $('table.mdr_rate').find('tr.amexplanno.planmin');
					var tr_max = $('table.mdr_rate').find('tr.amexplanno.planmax');
					
					tr_min.children('td:eq(' + td_index + ')').children('input').val(op.attr('data-min'));
					tr_max.children('td:eq(' + td_index + ')').children('input').val(op.attr('data-max'));
				})
			});
			
		});
		
		$('table.mdr_rate').children('tbody.hover').find('tr').each(function(i, ele){
			var tr = $(this);
			
			$(this).find('td').each(function(index, elmt){
				$(this).children('input, select').keydown(function (e) {
					if(e.keyCode == 9) {
						e.preventDefault();
						
						tr.next().children('td:eq(' + index + ')').children('input, select').focus();
					}
				});
			});
		});
	},
	
	create_outlet_detail : function(merchant_id, case_id) {
		var elmt, postdata;
		
		postdata = 'merchant_id=' + encodeURIComponent(merchant_id);
		postdata += '&case_id=' + encodeURIComponent(case_id);
		
		elmt = document.getElementById('registered_name');
		if(elmt.value.trim().length <= 0){
			mapUI.jq_message('Registered Name must not be blank.', 10);
			return;
		}
		if(elmt.value.length > 30){
			mapUI.jq_message('Registered Name must not be longer than 30 characters.', 10);
			return;
		}
		
		postdata += '&registered_name=' + encodeURIComponent(elmt.value);
		
		
		elmt = document.getElementById('business_reg_no');
		if(elmt.value.length > 0){
			var regexp = /^[A-Za-z0-9]+$/
			if(regexp.test(elmt.value) == false){
				mapUI.jq_message('Business Registered No. must have only alphabet or number.', 10);
				return;
			}
		}
		
		if(elmt.value.length > 16){
			mapUI.jq_message('Business Registration No. must not be longer than 16 characters.', 10);
			return;
		}
		
		postdata += '&registered_no=' + encodeURIComponent(elmt.value);
		 
		elmt = document.getElementById('gst_registration');
		postdata += '&gst_registration=' + encodeURIComponent(elmt.value);
		  
		elmt = document.getElementById('rmcd_approval_no');
		postdata += '&rmcd_approval_no=' + encodeURIComponent(elmt.value);
		
		
		elmt = document.getElementById('trading_name');
		if(elmt.value.trim().length <= 0){
			mapUI.jq_message('Trading Name must not be blank.', 10);
			return;
		}
		
		if(elmt.value.length > 25){
			mapUI.jq_message('Trading Name must not be longer than 25 characters.', 10);
			return;
		}
		
		postdata += '&trading_name=' + encodeURIComponent(elmt.value);
		
		elmt = document.getElementById('business_license_no');
		if(elmt.value.length > 0){
			var regexp = /^[A-Za-z0-9]+$/
			if(regexp.test(elmt.value) == false){
				mapUI.jq_message('Business License No. must have only alphabet or number.', 10);
				return;
			}
		}
		
		postdata += '&license_no=' + encodeURIComponent(elmt.value);
		
		elmt = document.getElementById('state');
		postdata += '&state=' + encodeURIComponent(elmt.value);
		
		elmt = document.getElementById('issuer');
		postdata += '&issuer=' + encodeURIComponent(elmt.value);
		
		elmt = document.getElementById('expiry_date');
		if(elmt.value.length > 0){
			var regexp = /^[0-9]{8}$/
			if(regexp.test(elmt.value) == false){
				mapUI.jq_message('Expiry Date must be in ddmmyyyy format, e.g. 31012015.', 10);
				return;
			}
		}
		postdata += '&expiry_date=' + encodeURIComponent(elmt.value);
		
		elmt = document.getElementById('risk_level');
		postdata += '&risk_level=' + encodeURIComponent(elmt.value);
		
		elmt = document.getElementById('contact_person');
		if(elmt.value.length > 25){
			mapUI.jq_message('Contact Person must not be longer than 25 characters.', 10);
			return;
		}
		
		postdata += '&contact_person=' + encodeURIComponent(elmt.value);
		
		elmt = document.getElementById('designation');
		if(elmt.value.length > 32){
			mapUI.jq_message('Designation Name must not be longer than 32 characters.', 10);
			return;
		}
		
		postdata += '&designation=' + encodeURIComponent(elmt.value);
		
		elmt = document.getElementById('email');
		if(elmt.value.length > 50){
			mapUI.jq_message('Email must not be longer than 50 characters.', 10);
			return;
		}
		
		postdata += '&email=' + encodeURIComponent(elmt.value);
		
		elmt = document.getElementById('telephone_no');
		if(elmt.value.length > 0){
			var regexp = /^[0-9]+$/
			if(regexp.test(elmt.value) == false){
				mapUI.jq_message('Telephone No. must have only number.', 10);
				return;
			}
		}
		
		if(elmt.value.length > 18){
			mapUI.jq_message('Telephone No. must not be longer than 18 characters.', 10);
			return;
		}
		
		postdata += '&telephone_no=' + encodeURIComponent(elmt.value.length > 0 ? elmt.value : '000000000000000000');
		
		elmt = document.getElementById('fax_no');
		if(elmt.value.length > 0){
			var regexp = /^[0-9]+$/
			if(regexp.test(elmt.value) == false){
				mapUI.jq_message('Fax No. must have only number.', 10);
				return;
			}
		}
		
		if(elmt.value.length > 16){
			mapUI.jq_message('Fax No. must not be longer than 16 characters.', 10);
			return;
		}
		
		postdata += '&fax_no=' + encodeURIComponent(elmt.value.length > 0 ? elmt.value : '0000000000000000');
		
		elmt = document.getElementById('esa_ref_no');
		postdata += '&esa_ref_no=' + encodeURIComponent(elmt.value);
		
		elmt = document.getElementById('no_of_terminal');
		if(elmt.value.length > 0){
			if(elmt.value.is_number() == false){
				mapUI.jq_message('No. of Terminal must be a number.', 10);
				return;
			}
			
			elmt.value = elmt.value.pad_left(2, '0');
		}
		postdata += '&no_of_terminal=' + encodeURIComponent(elmt.value);
		
		elmt = document.getElementById('terminal_rental_fee');
		if(elmt.value.trim().length > 0 && elmt.value.is_number() == false){
			mapUI.jq_message('Terminal Rental Fee must be a number.', 10);
			return;
		}
		postdata += '&terminal_rental_fee=' + encodeURIComponent(elmt.value);
		
		elmt = document.getElementById('terminal_owner');
		postdata += '&terminal_owner=' + encodeURIComponent(elmt.value);
		
		elmt = document.getElementById('terminal_deposit_wired');
		if(elmt.value.trim().length > 0 && isNaN(elmt.value)){
			mapUI.jq_message('Terminal Deposit (Wired) must be a number.', 10);
			return;
		}
		postdata += '&terminal_deposit_wired=' + encodeURIComponent(elmt.value);
		
		elmt = document.getElementById('terminal_deposit_wireless');
		if(elmt.value.trim().length > 0 && isNaN(elmt.value)){
			mapUI.jq_message('Terminal Deposit (Wireless) must be a number.', 10);
			return;
		}
		postdata += '&terminal_deposit_wireless=' + encodeURIComponent(elmt.value);
		
		elmt = document.getElementById('terminal_rental_deposit_wired');
		if(elmt.value.trim().length > 0 && isNaN(elmt.value)){
			mapUI.jq_message('Terminal Rental Deposit (Wired) must be a number.', 10);
			return;
		}
		postdata += '&terminal_rental_deposit_wired=' + encodeURIComponent(elmt.value);
		
		elmt = document.getElementById('terminal_rental_deposit_wireless');
		if(elmt.value.trim().length > 0 && isNaN(elmt.value)){
			mapUI.jq_message('Terminal Rental Deposit (Wireless) must be a number.', 10);
			return;
		}
		postdata += '&terminal_rental_deposit_wireless=' + encodeURIComponent(elmt.value);
		
		elmt = document.getElementById('advance_terminal_rental');
		if(elmt.value.trim().length > 0 && isNaN(elmt.value)){
			mapUI.jq_message('Advance Terminal Rental must be a number.', 10);
			return;
		}
		postdata += '&advance_terminal_rental=' + encodeURIComponent(elmt.value);
		
		elmt = document.getElementById('total_cheque_amt');
		if(elmt.value.trim().length > 0 && isNaN(elmt.value)){
			mapUI.jq_message('Total Cheque Amount must be a number.', 10);
			return;
		}
		postdata += '&total_cheque_amt=' + encodeURIComponent(elmt.value);
		
		elmt = document.getElementById('bank_issuer');
		postdata += '&bank_issuer=' + encodeURIComponent(elmt.value);
		
		elmt = document.getElementById('bank_branch');
		postdata += '&bank_branch=' + encodeURIComponent(elmt.value);
		
		elmt = document.getElementById('cheque_no');
		postdata += '&cheque_no=' + encodeURIComponent(elmt.value);
		
		elmt = document.getElementById('cheque_date');
		if(elmt.value.length > 0){
			var regexp = /^[0-9]{8}$/
			if(regexp.test(elmt.value) == false){
				mapUI.jq_message('Cheque Date must be in ddmmyyyy format, e.g. 31012015.', 10);
				return;
			}
		}
		postdata += '&cheque_date=' + encodeURIComponent(elmt.value);
		
		elmt = document.getElementById('terminal_id');
		postdata += '&terminal_id=' + encodeURIComponent(elmt.value);
		
		elmt = document.getElementById('terminal_id_no');
		postdata += '&terminal_id_no=' + encodeURIComponent(elmt.value);
		
		elmt = document.getElementById('terminal_install_date');
		postdata += '&terminal_install_date=' + encodeURIComponent(elmt.value);
		
		var license_type = "";
		$('#license_type').find('input[type=radio]').each(function(index, elmt){
            if($(this).is(':checked')){
            	license_type = $(this).val();
            }
        });
		
		postdata += '&license_type=' + encodeURIComponent(license_type);
		
		
		var callback = function(json){
            if(json.status == 'OK'){
            	mapUI.jq_message("Outlet Detail has been saved successfully.", 10);
            	   
            	var click_redirect = $('input#click_redirect').val();
            	var click_filter = $('input#click_filter').val();
            	
            	if(click_redirect.length > 0) {
            		click_redirect = encodeParam4Uri(click_redirect);
					var sep = click_redirect.indexOf("?") >= 0 ? "&" : "?";
					var q = window.location.search.replace(/^\?dispatch=[\w]+&/, "");
					
					if(click_filter.length > 0) {
						var re = new RegExp(click_filter, "g");
						q = q.replace(re, "");
					}
					else {
						q = q + '&o_id=' + json.outlet_id;
					}
					
            		window.location.href = jq_main_url + click_redirect + sep + q;
            	}
            	else {
            		window.location.href = jq_main_url + "/NewApp.do?dispatch=outlet_detail&m_id=" + encodeURIComponent(merchant_id) + "&c_id=" + encodeURIComponent(case_id) +  "&o_id=" + json.outlet_id;
            	}
            } else {
            	mapUI.jq_message(json.message, 10);
            }
        };
		
        var jq = {
            'method' : 'POST',
            'url' : jq_main_url + '/SubmitApp.do?dispatch=create_outlet_detail',
            'postdata' : postdata
        };
		
        mapUI.jq_call(jq, callback);
	},	
	
	edit_outlet_detail : function(case_id, outlet_id) {
		var elmt, postdata;
		
		postdata = 'case_id=' + encodeURIComponent(case_id);
		postdata += '&outlet_id=' + encodeURIComponent(outlet_id);
		
		elmt = document.getElementById('registered_name');
		if(elmt.value.trim().length <= 0){
			mapUI.jq_message('Registered Name must not be blank.', 10);
			return;
		}
		if(elmt.value.length > 30){
			mapUI.jq_message('Registered Name must not be longer than 30 characters.', 10);
			return;
		}
		
		postdata += '&registered_name=' + encodeURIComponent(elmt.value);
		
		
		elmt = document.getElementById('business_reg_no');
		if(elmt.value.length > 0){
			var regexp = /^[A-Za-z0-9]+$/
			if(regexp.test(elmt.value) == false){
				mapUI.jq_message('Business Registered No. must have only alphabet or number.', 10);
				return;
			}
		}
		
		if(elmt.value.length > 16){
			mapUI.jq_message('Business Registration No. must not be longer than 16 characters.', 10);
			return;
		}
		
		postdata += '&registered_no=' + encodeURIComponent(elmt.value);
		
		elmt = document.getElementById('gst_registration');
		postdata += '&gst_registration=' + encodeURIComponent(elmt.value);

		elmt = document.getElementById('rmcd_approval_no');
		postdata += '&rmcd_approval_no=' + encodeURIComponent(elmt.value);

		elmt = document.getElementById('trading_name');
		if(elmt.value.trim().length <= 0){
			mapUI.jq_message('Trading Name must not be blank.', 10);
			return;
		}
		
		if(elmt.value.length > 25){
			mapUI.jq_message('Trading Name must not be longer than 25 characters.', 10);
			return;
		}
		
		postdata += '&trading_name=' + encodeURIComponent(elmt.value);
		
		elmt = document.getElementById('business_license_no');
		if(elmt.value.length > 0){
			var regexp = /^[A-Za-z0-9]+$/
			if(regexp.test(elmt.value) == false){
				mapUI.jq_message('Business License No. must have only alphabet or number.', 10);
				return;
			}
		}
		
		postdata += '&license_no=' + encodeURIComponent(elmt.value);
		
		elmt = document.getElementById('state');
		postdata += '&state=' + encodeURIComponent(elmt.value);
		
		elmt = document.getElementById('issuer');
		postdata += '&issuer=' + encodeURIComponent(elmt.value);
		
		elmt = document.getElementById('expiry_date');
		if(elmt.value.length > 0){
			var regexp = /^[0-9]{8}$/
			if(regexp.test(elmt.value) == false){
				mapUI.jq_message('Expiry Date must be in ddmmyyyy format, e.g. 31012015.', 10);
				return;
			}
		}
		postdata += '&expiry_date=' + encodeURIComponent(elmt.value);
		
		elmt = document.getElementById('risk_level');
		postdata += '&risk_level=' + encodeURIComponent(elmt.value);
		
		elmt = document.getElementById('contact_person');
		if(elmt.value.length > 25){
			mapUI.jq_message('Contact Person must not be longer than 25 characters.', 10);
			return;
		}
		
		postdata += '&contact_person=' + encodeURIComponent(elmt.value);
		
		elmt = document.getElementById('designation');
		if(elmt.value.length > 32){
			mapUI.jq_message('Designation Name must not be longer than 32 characters.', 10);
			return;
		}
		
		postdata += '&designation=' + encodeURIComponent(elmt.value);
		
		elmt = document.getElementById('email');
		if(elmt.value.length > 50){
			mapUI.jq_message('Email must not be longer than 50 characters.', 10);
			return;
		}
		
		postdata += '&email=' + encodeURIComponent(elmt.value);
		
		elmt = document.getElementById('telephone_no');
		if(elmt.value.length > 0){
			var regexp = /^[0-9]+$/
			if(regexp.test(elmt.value) == false){
				mapUI.jq_message('Telephone No. must have only number.', 10);
				return;
			}
		}
		
		if(elmt.value.length > 18){
			mapUI.jq_message('Telephone No. must not be longer than 18 characters.', 10);
			return;
		}
		
		postdata += '&telephone_no=' + encodeURIComponent(elmt.value.length > 0 ? elmt.value : '000000000000000000');
		
		elmt = document.getElementById('fax_no');
		if(elmt.value.length > 0){
			var regexp = /^[0-9]+$/
			if(regexp.test(elmt.value) == false){
				mapUI.jq_message('Fax No. must have only number.', 10);
				return;
			}
		}
		
		if(elmt.value.length > 16){
			mapUI.jq_message('Fax No. must not be longer than 16 characters.', 10);
			return;
		}
		
		postdata += '&fax_no=' + encodeURIComponent(elmt.value.length > 0 ? elmt.value : '0000000000000000');
		
		elmt = document.getElementById('esa_ref_no');
		postdata += '&esa_ref_no=' + encodeURIComponent(elmt.value);
		
		elmt = document.getElementById('no_of_terminal');
		if(elmt.value.length > 0){
			if(elmt.value.is_number() == false){
				mapUI.jq_message('No. of Terminal must be a number.', 10);
				return;
			}
			
			elmt.value = elmt.value.pad_left(2, '0');
		}
		postdata += '&no_of_terminal=' + encodeURIComponent(elmt.value);
		
		elmt = document.getElementById('terminal_rental_fee');
		postdata += '&terminal_rental_fee=' + encodeURIComponent(elmt.value);
		
		elmt = document.getElementById('terminal_owner');
		postdata += '&terminal_owner=' + encodeURIComponent(elmt.value);
		
		elmt = document.getElementById('terminal_deposit_wired');
		postdata += '&terminal_deposit_wired=' + encodeURIComponent(elmt.value);
		
		elmt = document.getElementById('terminal_deposit_wireless');
		postdata += '&terminal_deposit_wireless=' + encodeURIComponent(elmt.value);
		
		elmt = document.getElementById('terminal_rental_deposit_wired');
		postdata += '&terminal_rental_deposit_wired=' + encodeURIComponent(elmt.value);
		
		elmt = document.getElementById('terminal_rental_deposit_wireless');
		postdata += '&terminal_rental_deposit_wireless=' + encodeURIComponent(elmt.value);
		
		elmt = document.getElementById('advance_terminal_rental');
		postdata += '&advance_terminal_rental=' + encodeURIComponent(elmt.value);
		
		elmt = document.getElementById('total_cheque_amt');
		postdata += '&total_cheque_amt=' + encodeURIComponent(elmt.value);
		
		elmt = document.getElementById('bank_issuer');
		postdata += '&bank_issuer=' + encodeURIComponent(elmt.value);
		
		elmt = document.getElementById('bank_branch');
		postdata += '&bank_branch=' + encodeURIComponent(elmt.value);
		
		elmt = document.getElementById('cheque_no');
		postdata += '&cheque_no=' + encodeURIComponent(elmt.value);
		
		elmt = document.getElementById('cheque_date');
		if(elmt.value.length > 0){
			var regexp = /^[0-9]{8}$/
			if(regexp.test(elmt.value) == false){
				mapUI.jq_message('Cheque Date must be in ddmmyyyy format, e.g. 31012015.', 10);
				return;
			}
		}
		postdata += '&cheque_date=' + encodeURIComponent(elmt.value);
		
		elmt = document.getElementById('terminal_id');
		postdata += '&terminal_id=' + encodeURIComponent(elmt.value);
		
		elmt = document.getElementById('terminal_id_no');
		postdata += '&terminal_id_no=' + encodeURIComponent(elmt.value);
		
		elmt = document.getElementById('terminal_install_date');
		postdata += '&terminal_install_date=' + encodeURIComponent(elmt.value);
		
		var license_type = "";
		$('#license_type').find('input[type=radio]').each(function(index, elmt){
            if($(this).is(':checked')){
            	license_type = $(this).val();
            }
        });
		
		postdata += '&license_type=' + encodeURIComponent(license_type);
		
		
		var callback = function(json){
            if(json.status == 'OK'){
            	mapUI.jq_message("Outlet Detail has been saved successfully.", 10);
            	  
            	var click_redirect = $('input#click_redirect').val();
            	var click_filter = $('input#click_filter').val();
            	
            	if(click_redirect.length > 0) {
            		click_redirect = encodeParam4Uri(click_redirect);
            		var sep = click_redirect.indexOf("?") >= 0 ? "&" : "?";
					var q = window.location.search.replace(/^\?dispatch=[\w]+&/, "");
					
					if(click_filter.length > 0) {
						var re = new RegExp(click_filter, "g");
						q = q.replace(re, "");
					}
					
            		window.location.href = jq_main_url + click_redirect + sep + q;
            	}
            	
            } else {
            	mapUI.jq_message(json.message, 10);
            }
        };
		
        var jq = {
            'method' : 'POST',
            'url' : jq_main_url + '/SubmitApp.do?dispatch=edit_outlet_detail',
            'postdata' : postdata
        };
		
        mapUI.jq_call(jq, callback);
	},	
	
	create_payment_info : function(case_id, outlet_id) {
		var elmt, postdata;
		var data = {};
		
		postdata = 'case_id=' + encodeURIComponent(case_id);
		postdata += '&outlet_id=' + encodeURIComponent(outlet_id);
		
		elmt = document.getElementById('cust_name');
		if(elmt.value.length > 40){
			mapUI.jq_message('Customer Name must not be longer than 40 characters.', 10);
			return;
		}
		
		data['cust_1'] = elmt.value;
		postdata += '&cust_name=' + encodeURIComponent(elmt.value);
		
		elmt = document.getElementById('cust_gcif');
		if(elmt.value.length > 9){
			mapUI.jq_message('GCIF No. must not be longer than 9 characters.', 10);
			return;
		}
		
		data['cust_2'] = elmt.value;
		postdata += '&cust_gcif=' + encodeURIComponent(elmt.value);
		
		elmt = document.getElementById('cust_sub_segment');
		
		if(elmt.value.length > 0){
			var regexp = /^[0-9]{2}$/
			if(regexp.test(elmt.value) == false){
				mapUI.jq_message('Sub Market Segment Code must be a 2 digits numeric value.', 10);
				return;
			}
		}	
		
		data['cust_3'] = elmt.value;
		postdata += '&cust_sub_segment=' + encodeURIComponent(elmt.value);
		
		
		var visa_master = "";
		$('input[type=radio][name="visa_master"]').each(function(index, elmt){
            if($(this).is(':checked')){
            	visa_master = $(this).val();
            }
        });
			
		
		if(visa_master == "credit_maybank"){
			if(document.getElementById('cust_name').value.length <= 0 || document.getElementById('cust_gcif').value.length <= 0 || document.getElementById('cust_sub_segment').value.length <= 0){
				mapUI.jq_message('Maybank Customer Information must not be blank.', 10);
				return;
			}
		}
		
		data['visa_1'] = visa_master;
		postdata += '&visa_master=' + encodeURIComponent(visa_master);
		
		elmt = document.getElementById('visa_master_credit_maybank');
		if(elmt.value.length > 12){
			mapUI.jq_message('Visa & MasterCard Payment Information Maybank Current Account No. must not be longer than 12 characters.', 10);
			return;
		}
		data['visa_2'] = elmt.value;
		postdata += '&visa_master_credit_maybank=' + encodeURIComponent(elmt.value);
		
		elmt = document.getElementById('visa_master_interbank_giro_service');
		data['visa_3'] = elmt.value;
		postdata += '&visa_master_interbank_giro_service=' + encodeURIComponent(elmt.value);
		
		elmt = document.getElementById('visa_master_interbank_giro_bank');
		data['visa_4'] = elmt.value;
		postdata += '&visa_master_interbank_giro_bank=' + encodeURIComponent(elmt.value);
		
		elmt = document.getElementById('visa_master_interbank_giro_acc_no');
		if(elmt.value.length > 40){
			mapUI.jq_message('Visa & MasterCard Payment Information InterBank Giro Current Account No. must not be longer than 40 characters.', 10);
			return;
		}
		
		data['visa_5'] = elmt.value;
		postdata += '&visa_master_interbank_giro_acc_no=' + encodeURIComponent(elmt.value);
		
		elmt = document.getElementById('visa_master_center_code');
		data['visa_6'] = elmt.value;
		postdata += '&visa_master_center_code=' + encodeURIComponent(elmt.value);
		
		elmt = document.getElementById('visa_master_branch_code');
		if(elmt.value.length > 5){
			mapUI.jq_message('Visa & MasterCard Payment Information Servicing Branch Code must not be longer than 5 characters.', 10);
			return;
		}
		data['visa_7'] = elmt.value;
		postdata += '&visa_master_branch_code=' + encodeURIComponent(elmt.value);
		
		var amex = "";
		$('input[type=radio][name="amex"]').each(function(index, elmt){
            if($(this).is(':checked')){
            	amex = $(this).val();
            }
        });
			
		
		if(amex == "credit_maybank"){
			if(document.getElementById('cust_name').value.length <= 0 || document.getElementById('cust_gcif').value.length <= 0 || document.getElementById('cust_sub_segment').value.length <= 0){
				mapUI.jq_message('Maybank Customer Information must not be blank.', 10);
				return;
			}
		}
		
		data['amex_1'] = amex;
		postdata += '&amex=' + encodeURIComponent(amex);
		
		elmt = document.getElementById('amex_credit_maybank');
		if(elmt.value.length > 12){
			mapUI.jq_message('Amex Payment Information Maybank Current Account No. must not be longer than 12 characters.', 10);
			return;
		}
		data['amex_2'] = elmt.value;
		postdata += '&amex_credit_maybank=' + encodeURIComponent(elmt.value);
		
		elmt = document.getElementById('amex_interbank_giro_service');
		if(elmt.value.length > 19){
			mapUI.jq_message('Amex Payment Information InterBank Giro Current Account No. must not be longer than 19 characters.', 10);
			return;
		}
		data['amex_3'] = elmt.value;
		postdata += '&amex_interbank_giro_service=' + encodeURIComponent(elmt.value);
		
		elmt = document.getElementById('amex_interbank_giro_bank_code');
		data['amex_4'] = elmt.value;
		postdata += '&amex_interbank_giro_bank_code=' + encodeURIComponent(elmt.value);
		
		elmt = document.getElementById('amex_banker_cheque_bank_code');
		data['amex_5'] = elmt.value;
		postdata += '&amex_banker_cheque_bank_code=' + encodeURIComponent(elmt.value);
		
		elmt = document.getElementById('amex_payment_method');
		data['amex_6'] = elmt.value;
		postdata += '&amex_payment_method=' + encodeURIComponent(elmt.value);
		
		elmt = document.getElementById('amex_payee_mid');
		if(elmt.value.length > 9){
			mapUI.jq_message('Amex Payment Information Payee MID No. must not be longer than 9 characters.', 10);
			return;
		}
		data['amex_7'] = elmt.value;
		postdata += '&amex_payee_mid=' + encodeURIComponent(elmt.value);
		
		elmt = document.getElementById('amex_payment_plan');
		data['amex_8'] = elmt.value;
		postdata += '&amex_payment_plan=' + encodeURIComponent(elmt.value);
		
		elmt = document.getElementById('amex_center_code');
		data['amex_9'] = elmt.value;
		postdata += '&amex_center_code=' + encodeURIComponent(elmt.value);
		
		elmt = document.getElementById('amex_branch_code');
		data['amex_10'] = elmt.value;
		postdata += '&amex_branch_code=' + encodeURIComponent(elmt.value);
		
		var union_pay = "";
		$('input[type=radio][name="union_pay"]').each(function(index, elmt){
            if($(this).is(':checked')){
            	union_pay = $(this).val();
            }
        });
			

		data['union_pay_1'] = union_pay;
		postdata += '&union_pay=' + encodeURIComponent(union_pay);
		
		elmt = document.getElementById('ezypay_center_code');
		data['ezypay_1'] = elmt.value;
		postdata += '&ezypay_center_code=' + encodeURIComponent(elmt.value);
		
		elmt = document.getElementById('ezypay_branch_code');
		data['ezypay_2'] = elmt.value;
		postdata += '&ezypay_branch_code=' + encodeURIComponent(elmt.value);
		
		elmt = document.getElementById('maybank_philippine_center_code');
		data['mbb_phi_1'] = elmt.value;
		postdata += '&maybank_philippine_center_code=' + encodeURIComponent(elmt.value);
		
		elmt = document.getElementById('maybank_philippine_branch_code');
		data['mbb_phi_2'] = elmt.value;
		postdata += '&maybank_philippine_branch_code=' + encodeURIComponent(elmt.value);
		
		elmt = document.getElementById('maybank_singapore_center_code');
		data['mbb_sg_1'] = elmt.value;
		postdata += '&maybank_philippine_branch_code=' + encodeURIComponent(elmt.value);
		
		elmt = document.getElementById('maybank_singapore_branch_code');
		data['mbb_sg_2'] = elmt.value;
		postdata += '&maybank_singapore_branch_code=' + encodeURIComponent(elmt.value);
		
		
		postdata = 'case_id=' + encodeURIComponent(case_id);
		postdata += '&outlet_id=' + encodeURIComponent(outlet_id);
		postdata += "&payment_info=" + encodeURIComponent(JSON.stringify(data));
		
		var callback = function(json){
            if(json.status == 'OK'){
            	mapUI.jq_message("Payment Information has been saved successfully.", 10);
            	
            	var click_redirect = $('input#click_redirect').val();
            	var click_filter = $('input#click_filter').val();
            	
            	if(click_redirect.length > 0) {
            		click_redirect = encodeParam4Uri(click_redirect);
            		var sep = click_redirect.indexOf("?") >= 0 ? "&" : "?";
					var q = window.location.search.replace(/^\?dispatch=[\w]+&/, "");
					
					if(click_filter.length > 0) {
						var re = new RegExp(click_filter, "g");
						q = q.replace(re, "");
					}
					
            		window.location.href = jq_main_url + click_redirect + sep + q;
            	}
            	
            	
            } else {
            	mapUI.jq_message(json.message, 10);
            }
        };
		
        var jq = {
            'method' : 'POST',
            'url' : jq_main_url + '/SubmitApp.do?dispatch=create_payment_info',
            'postdata' : postdata
        };

        mapUI.jq_call(jq, callback);
	},	
	
	create_statement_opt : function(case_id, outlet_id) {
		var elmt, postdata;
		var data = {};
		
		var visa_1 = "";
		$('input[type=radio][name="visa_1"]').each(function(index, elmt){
            if($(this).is(':checked')){
            	visa_1 = $(this).val();
            }
        });
			
			
		data['visa_1'] = visa_1;
		
		elmt = document.getElementById('visa_2');
		data['visa_2'] = elmt.value;
		
		elmt = document.getElementById('visa_3');
		data['visa_3'] = elmt.value;
		
		
		var amex_1 = "";
		$('input[type=radio][name="amex_1"]').each(function(index, elmt){
            if($(this).is(':checked')){
            	amex_1 = $(this).val();
            }
        });
			

		data['amex_1'] = amex_1;
		
		elmt = document.getElementById('amex_2');
		if(elmt.value.length > 50){
			mapUI.jq_message('Amex Statement Option Email Address must not be longer than 50 characters.', 10);
			return;
		}
		
		data['amex_2'] = elmt.value;
		
		
		postdata = 'case_id=' + encodeURIComponent(case_id);
		postdata += '&outlet_id=' + encodeURIComponent(outlet_id);
		postdata += "&statement_opt=" + encodeURIComponent(JSON.stringify(data));
		
		var callback = function(json){
            if(json.status == 'OK'){
            	mapUI.jq_message("Statement Option has been saved successfully.", 10);
            	
            	var click_redirect = $('input#click_redirect').val();
            	var click_filter = $('input#click_filter').val();
            	
            	if(click_redirect.length > 0) {
            		click_redirect = encodeParam4Uri(click_redirect);
            		var sep = click_redirect.indexOf("?") >= 0 ? "&" : "?";
					var q = window.location.search.replace(/^\?dispatch=[\w]+&/, "");
					
					if(click_filter.length > 0) {
						var re = new RegExp(click_filter, "g");
						q = q.replace(re, "");
					}
					
            		window.location.href = jq_main_url + click_redirect + sep + q;
            	}
            	
            } else {
            	mapUI.jq_message(json.message, 10);
            }
        };
		
        var jq = {
            'method' : 'POST',
            'url' : jq_main_url + '/SubmitApp.do?dispatch=create_statement_opt',
            'postdata' : postdata
        };
        
        mapUI.jq_call(jq, callback);
	},	
	
	create_other_info : function(case_id, outlet_id) {
		var elmt, postdata;
		
		var data = {};
		
		elmt = document.getElementById('officer_code');
		if(elmt.value.length <= 0){
			mapUI.jq_message('Officer Code must not be blank.', 10);
			return;
		}
		if(elmt.value.length > 3){
			mapUI.jq_message('Officer Code must not be longer than 3 characters.', 10);
			return;
		}
		data['officer_code'] = elmt.value;
		
		elmt = document.getElementById('user_code_1');
		if(elmt.value.length > 2){
			mapUI.jq_message('User Code 1 must not be longer than 2 characters.', 10);
			return;
		}
		
		if(elmt.value.length > 0){
			data['user_code_1'] = elmt.value;
		} else {
			data['user_code_1'] = ' ';
		}
		
		elmt = document.getElementById('user_code_2');
		if(elmt.value.length > 2){
			mapUI.jq_message('User Code 2 must not be longer than 2 characters.', 10);
			return;
		}
		
		if(elmt.value.length > 0){
			data['user_code_2'] = elmt.value;
		} else {
			data['user_code_2'] = ' ';
		}

		elmt = document.getElementById('user_code_3');
		if(elmt.value.length > 2){
			mapUI.jq_message('User Code 3 must not be longer than 2 characters.', 10);
			return;
		}
		
		if(elmt.value.length > 0){
			data['user_code_3'] = elmt.value;
		} else {
			data['user_code_3'] = ' ';
		}
		
		elmt = document.getElementById('chain_merchant');
		if(elmt.value.length > 9){
			mapUI.jq_message('Chain Merchant must not be longer than 9 characters.', 10);
			return;
		}
		data['chain_merchant'] = elmt.value;
		
		elmt = document.getElementById('hierarchy_no');
		if(elmt.value.length > 9){
			mapUI.jq_message('Hierarchy No. must not be longer than 9 characters.', 10);
			return;
		}
		data['hierarchy_no'] = elmt.value;
		
		elmt = document.getElementById('level');
		data['level'] = elmt.value;
		
		elmt = document.getElementById('servicing_rep');
		data['servicing_rep'] = elmt.value;
		
		elmt = document.getElementById('sales_rep');
		data['sales_rep'] = elmt.value;
		
		elmt = document.getElementById('level_5');
		if(elmt.value.length > 9){
			mapUI.jq_message('Level 5 must not be longer than 9 characters.', 10);
			return;
		}
		data['level_5'] = elmt.value;
		
		elmt = document.getElementById('level_6');
		if(elmt.value.length > 9){
			mapUI.jq_message('Level 6 must not be longer than 9 characters.', 10);
			return;
		}
		data['level_6'] = elmt.value;
		
		postdata = 'case_id=' + encodeURIComponent(case_id);
		postdata += '&outlet_id=' + encodeURIComponent(outlet_id);
		postdata += "&other_info=" + encodeURIComponent(JSON.stringify(data));
		
		var callback = function(json){
            if(json.status == 'OK'){
            	mapUI.jq_message("Other Information has been saved successfully.", 10);
            	
            	var click_redirect = $('input#click_redirect').val();
            	var click_filter = $('input#click_filter').val();
            	
            	if(click_redirect.length > 0) {
            		click_redirect = encodeParam4Uri(click_redirect);
            		var sep = click_redirect.indexOf("?") >= 0 ? "&" : "?";
					var q = window.location.search.replace(/^\?dispatch=[\w]+&/, "");
					
					if(click_filter.length > 0) {
						var re = new RegExp(click_filter, "g");
						q = q.replace(re, "");
					}
					
            		window.location.href = jq_main_url + click_redirect + sep + q;
            	}
            	
            } else {
            	mapUI.jq_message(json.message, 10);
            }
        };
		
        var jq = {
            'method' : 'POST',
            'url' : jq_main_url + '/SubmitApp.do?dispatch=create_other_info',
            'postdata' : postdata
        };
        
        mapUI.jq_call(jq, callback);
	},	

	create_physical_address : function(case_id, outlet_id) {
		var elmt, postdata;
		
		var data = {};
		
		elmt = document.getElementById('line_1');
		if(elmt.value.length > 30){
			mapUI.jq_message('Line 1 must not be longer than 30 characters.', 10);
			return;
		}
		
		if(elmt.value.length > 0){
			data['line_1'] = elmt.value;
		} else {
			data['line_1'] = ' ';
		}
		
		if(data['line_1'].toString().length < 40){
			data['line_1'] = data['line_1'].toString().pad_right(40, ' ');
		}
		
		elmt = document.getElementById('line_2');
		if(elmt.value.length > 30){
			mapUI.jq_message('Line 2 must not be longer than 30 characters.', 10);
			return;
		}
		
		if(elmt.value.length > 0){
			data['line_2'] = elmt.value;
		} else {
			data['line_2'] = ' ';
		}
		
		if(data['line_2'].toString().length < 40){
			data['line_2'] = data['line_2'].toString().pad_right(40, ' ');
		}
		
		
		elmt = document.getElementById('line_3');
		if(elmt.value.length > 30){
			mapUI.jq_message('Line 3 must not be longer than 30 characters.', 10);
			return;
		}
		
		if(elmt.value.length > 0){
			data['line_3'] = elmt.value;
		} else {
			data['line_3'] = ' ';
		}
		
		if(data['line_3'].toString().length < 40){
			data['line_3'] = data['line_3'].toString().pad_right(40, ' ');
		}

		elmt = document.getElementById('line_4');
		if(elmt.value.length > 30){
			mapUI.jq_message('Line 4 must not be longer than 30 characters.', 10);
			return;
		}
		
		if(elmt.value.length > 0){
			data['line_4'] = elmt.value;
		} else {
			data['line_4'] = ' ';
		}
		
		if(data['line_4'].toString().length < 40){
			data['line_4'] = data['line_4'].toString().pad_right(40, ' ');
		}
		
		elmt = document.getElementById('postal_code');
		if(elmt.value.length > 9){
			mapUI.jq_message('Postal Code must not be longer than 9 characters.', 10);
			return;
		}
		
		if(elmt.value.length > 0){
			data['postal_code'] = elmt.value;
		} else {
			data['postal_code'] = ' ';
		}
		
		if(data['postal_code'].toString().length < 15){
			data['postal_code'] = data['postal_code'].toString().pad_right(15, ' ');
		}
		
		elmt = document.getElementById('city');
		if(elmt.value.length > 13){
			mapUI.jq_message('City must not be longer than 13 characters.', 10);
			return;
		}
		
		if(elmt.value.length > 0){
			data['city'] = elmt.value;
		} else {
			data['city'] = ' ';
		}
		
		if(data['city'].toString().length < 32){
			data['city'] = data['city'].toString().pad_right(32, ' ');
		}
		
		elmt = document.getElementById('region_code');
		data['region_code'] = elmt.value;
		
		postdata = 'case_id=' + encodeURIComponent(case_id);
		postdata += '&outlet_id=' + encodeURIComponent(outlet_id);
		postdata += "&address=" + encodeURIComponent(JSON.stringify(data));
		
		var callback = function(json){
            if(json.status == 'OK'){
            	mapUI.jq_message("Physical Address has been saved successfully.", 10);
            	
            	var click_redirect = $('input#click_redirect').val();
            	var click_filter = $('input#click_filter').val();
            	
            	if(click_redirect.length > 0) {
            		click_redirect = encodeParam4Uri(click_redirect);
            		var sep = click_redirect.indexOf("?") >= 0 ? "&" : "?";
					var q = window.location.search.replace(/^\?dispatch=[\w]+&/, "");
					
					if(click_filter.length > 0) {
						var re = new RegExp(click_filter, "g");
						q = q.replace(re, "");
					}
					
            		window.location.href = jq_main_url + click_redirect + sep + q;
            	}
            	
            } else {
            	mapUI.jq_message(json.message, 10);
            }
        };
		
        var jq = {
            'method' : 'POST',
            'url' : jq_main_url + '/SubmitApp.do?dispatch=create_physical_address',
            'postdata' : postdata
        };
        
        mapUI.jq_call(jq, callback);
	},
	
	create_payment_address : function(case_id, outlet_id) {
		var elmt, postdata;
		
		var data = {};
		
		elmt = document.getElementById('line_1');
		if(elmt.value.length > 30){
			mapUI.jq_message('Line 1 must not be longer than 30 characters.', 10);
			return;
		}
		
		if(elmt.value.length > 0){
			data['line_1'] = elmt.value;
		} else {
			data['line_1'] = ' ';
		}
		
		if(data['line_1'].toString().length < 40){
			data['line_1'] = data['line_1'].toString().pad_right(40, ' ');
		}
		
		elmt = document.getElementById('line_2');
		if(elmt.value.length > 30){
			mapUI.jq_message('Line 2 must not be longer than 30 characters.', 10);
			return;
		}
		
		if(elmt.value.length > 0){
			data['line_2'] = elmt.value;
		} else {
			data['line_2'] = ' ';
		}
		
		if(data['line_2'].toString().length < 40){
			data['line_2'] = data['line_2'].toString().pad_right(40, ' ');
		}
		
		
		elmt = document.getElementById('line_3');
		if(elmt.value.length > 30){
			mapUI.jq_message('Line 3 must not be longer than 30 characters.', 10);
			return;
		}
		
		if(elmt.value.length > 0){
			data['line_3'] = elmt.value;
		} else {
			data['line_3'] = ' ';
		}
		
		if(data['line_3'].toString().length < 40){
			data['line_3'] = data['line_3'].toString().pad_right(40, ' ');
		}

		elmt = document.getElementById('line_4');
		if(elmt.value.length > 30){
			mapUI.jq_message('Line 4 must not be longer than 30 characters.', 10);
			return;
		}
		
		if(elmt.value.length > 0){
			data['line_4'] = elmt.value;
		} else {
			data['line_4'] = ' ';
		}
		
		if(data['line_4'].toString().length < 40){
			data['line_4'] = data['line_4'].toString().pad_right(40, ' ');
		}
		
		elmt = document.getElementById('postal_code');
		if(elmt.value.length > 9){
			mapUI.jq_message('Postal Code must not be longer than 9 characters.', 10);
			return;
		}
		
		if(elmt.value.length > 0){
			data['postal_code'] = elmt.value;
		} else {
			data['postal_code'] = ' ';
		}
		
		if(data['postal_code'].toString().length < 15){
			data['postal_code'] = data['postal_code'].toString().pad_right(15, ' ');
		}
		
		elmt = document.getElementById('city');
		if(elmt.value.length > 13){
			mapUI.jq_message('City must not be longer than 13 characters.', 10);
			return;
		}
		
		if(elmt.value.length > 0){
			data['city'] = elmt.value;
		} else {
			data['city'] = ' ';
		}
		
		if(data['city'].toString().length < 32){
			data['city'] = data['city'].toString().pad_right(32, ' ');
		}
		
		elmt = document.getElementById('region_code');
		data['region_code'] = elmt.value;
		
		postdata = 'case_id=' + encodeURIComponent(case_id);
		postdata += '&outlet_id=' + encodeURIComponent(outlet_id);
		postdata += "&address=" + encodeURIComponent(JSON.stringify(data));
		
		var callback = function(json){
            if(json.status == 'OK'){
            	mapUI.jq_message("Payment Address has been saved successfully.", 10);
            	
            	var click_redirect = $('input#click_redirect').val();
            	var click_filter = $('input#click_filter').val();
            	
            	if(click_redirect.length > 0) {
            		click_redirect = encodeParam4Uri(click_redirect);
            		var sep = click_redirect.indexOf("?") >= 0 ? "&" : "?";
					var q = window.location.search.replace(/^\?dispatch=[\w]+&/, "");
					
					if(click_filter.length > 0) {
						var re = new RegExp(click_filter, "g");
						q = q.replace(re, "");
					}
					
            		window.location.href = jq_main_url + click_redirect + sep + q;
            	}
            	
            } else {
            	mapUI.jq_message(json.message, 10);
            }
        };
		
        var jq = {
            'method' : 'POST',
            'url' : jq_main_url + '/SubmitApp.do?dispatch=create_payment_address',
            'postdata' : postdata
        };
        
        mapUI.jq_call(jq, callback);
	},
	
	create_correspondence_address : function(case_id, outlet_id) {
		var elmt, postdata;
		
		var data = {};
		
		elmt = document.getElementById('line_1');
		if(elmt.value.length > 30){
			mapUI.jq_message('Line 1 must not be longer than 30 characters.', 10);
			return;
		}
		
		if(elmt.value.length > 0){
			data['line_1'] = elmt.value;
		} else {
			data['line_1'] = ' ';
		}
		
		if(data['line_1'].toString().length < 40){
			data['line_1'] = data['line_1'].toString().pad_right(40, ' ');
		}
		
		elmt = document.getElementById('line_2');
		if(elmt.value.length > 30){
			mapUI.jq_message('Line 2 must not be longer than 30 characters.', 10);
			return;
		}
		
		if(elmt.value.length > 0){
			data['line_2'] = elmt.value;
		} else {
			data['line_2'] = ' ';
		}
		
		if(data['line_2'].toString().length < 40){
			data['line_2'] = data['line_2'].toString().pad_right(40, ' ');
		}
		
		
		elmt = document.getElementById('line_3');
		if(elmt.value.length > 30){
			mapUI.jq_message('Line 3 must not be longer than 30 characters.', 10);
			return;
		}
		
		if(elmt.value.length > 0){
			data['line_3'] = elmt.value;
		} else {
			data['line_3'] = ' ';
		}
		
		if(data['line_3'].toString().length < 40){
			data['line_3'] = data['line_3'].toString().pad_right(40, ' ');
		}

		elmt = document.getElementById('line_4');
		if(elmt.value.length > 30){
			mapUI.jq_message('Line 4 must not be longer than 30 characters.', 10);
			return;
		}
		
		if(elmt.value.length > 0){
			data['line_4'] = elmt.value;
		} else {
			data['line_4'] = ' ';
		}
		
		if(data['line_4'].toString().length < 40){
			data['line_4'] = data['line_4'].toString().pad_right(40, ' ');
		}
		
		elmt = document.getElementById('postal_code');
		if(elmt.value.length > 9){
			mapUI.jq_message('Postal Code must not be longer than 9 characters.', 10);
			return;
		}
		
		if(elmt.value.length > 0){
			data['postal_code'] = elmt.value;
		} else {
			data['postal_code'] = ' ';
		}
		
		if(data['postal_code'].toString().length < 15){
			data['postal_code'] = data['postal_code'].toString().pad_right(15, ' ');
		}
		
		elmt = document.getElementById('city');
		if(elmt.value.length > 13){
			mapUI.jq_message('City must not be longer than 13 characters.', 10);
			return;
		}
		
		if(elmt.value.length > 0){
			data['city'] = elmt.value;
		} else {
			data['city'] = ' ';
		}
		
		if(data['city'].toString().length < 32){
			data['city'] = data['city'].toString().pad_right(32, ' ');
		}
		
		elmt = document.getElementById('region_code');
		data['region_code'] = elmt.value;
		
		postdata = 'case_id=' + encodeURIComponent(case_id);
		postdata += '&outlet_id=' + encodeURIComponent(outlet_id);
		postdata += "&address=" + encodeURIComponent(JSON.stringify(data));
		
		var callback = function(json){
            if(json.status == 'OK'){
            	mapUI.jq_message("Correspondence Address has been saved successfully.", 10);
            	
            	var click_redirect = $('input#click_redirect').val();
            	var click_filter = $('input#click_filter').val();
            	
            	if(click_redirect.length > 0) {
            		click_redirect = encodeParam4Uri(click_redirect);
            		var sep = click_redirect.indexOf("?") >= 0 ? "&" : "?";
					var q = window.location.search.replace(/^\?dispatch=[\w]+&/, "");
					
					if(click_filter.length > 0) {
						var re = new RegExp(click_filter, "g");
						q = q.replace(re, "");
					}
					
            		window.location.href = jq_main_url + click_redirect + sep + q;
            	}
            	
            } else {
            	mapUI.jq_message(json.message, 10);
            }
        };
		
        var jq = {
            'method' : 'POST',
            'url' : jq_main_url + '/SubmitApp.do?dispatch=create_correspondence_address',
            'postdata' : postdata
        };
        
        mapUI.jq_call(jq, callback);
	},
	
	create_mdr : function(case_id, outlet_id) {
		var postdata;
		var data = {};

		var regexp = /^\s*-?[0-9]\d*(\.\d{1,2})?\s*$/
		
		var gst_rate_elmts = document.getElementsByClassName("gst_rate");
		var i;
		for (i = 0; i < gst_rate_elmts.length; i++) {
			
			if (gst_rate_elmts[i].value == '') {
				mapUI.jq_message('GST Rate must not be blank.', 10);
				return;
			}
			if(regexp.test(gst_rate_elmts[i].value) == false){
				mapUI.jq_message('GST Rate must be a numeric value.', 10);
				return;
			}
		}
		
		$('table.mdr_rate').find('tbody').find('tr').find('td').each(function(index, elmt){
			var input = $(this).find('input[type="text"]:eq(0)');
			var select = $(this).find('select');
			
			if(input.length > 0) {
				//postdata += '&' + input.attr('name') + '=' + encodeURIComponent(input.val());
				data[input.attr('name')] = input.val();
			}
			else if(select.length > 0) {
				//console.log(select.attr('name'));
				//alert(select.attr('name'));
				data[select.attr('name')] = select.val();
			}
		});
		
		postdata = 'case_id=' + encodeURIComponent(case_id);
		postdata += '&outlet_id=' + encodeURIComponent(outlet_id);
		postdata += "&mdr=" + encodeURIComponent(JSON.stringify(data));
		
		var callback = function(json){
            if(json.status == 'OK'){
            	mapUI.jq_message("MDR has been saved successfully.", 10);
            	
            	var click_redirect = $('input#click_redirect').val();
            	var click_filter = $('input#click_filter').val();
            	
            	if(click_redirect.length > 0) {
            		click_redirect = encodeParam4Uri(click_redirect);
            		var sep = click_redirect.indexOf("?") >= 0 ? "&" : "?";
					var q = window.location.search.replace(/^\?dispatch=[\w]+&/, "");
					
					if(click_filter.length > 0) {
						var re = new RegExp(click_filter, "g");
						q = q.replace(re, "");
					}
					
            		window.location.href = jq_main_url + click_redirect + sep + q;
            	}
            	
            } else {
            	mapUI.jq_message(json.message, 10);
            }
        };
		
        var jq = {
            'method' : 'POST',
            'url' : jq_main_url + '/SubmitApp.do?dispatch=create_mdr',
            'postdata' : postdata
        };
        
        mapUI.jq_call(jq, callback);
	},
	
	delete_submit : function(case_id, merchant_id, outlet_id){
		var elmt, postdata;
		
		postdata = 'case_id=' + encodeURIComponent(case_id);
		postdata += '&merchant_id=' + encodeURIComponent(merchant_id);
		postdata += '&outlet_id=' + encodeURIComponent(outlet_id);
		
		if(confirm('Proceed to remove this outlet from this application?')){
			var callback = function(json){
				if(json.status == 'OK'){
					mapUI.jq_message("Outlet information removed successfully.", 10);
					window.location.href = jq_main_url + '/NewApp.do?dispatch=outlet_detail&m_id=' + encodeURIComponent(merchant_id) + '&c_id=' + encodeURIComponent(case_id);
					
				} else {
					mapUI.jq_message(json.message, 10);
				}
			};
			
			var jq = {
				'method' : 'POST',
				'url' : jq_main_url + '/SubmitApp.do?dispatch=outlet_delete',
				'postdata' : postdata
			};
			
			mapUI.jq_call(jq, callback);
		}
	},
	
	load_state_issuer : function(state, issuer){
		var options = "<option value=''></option>";
		
		
		if(state == "WILAYAH PERSEKUTUAN KUALA LUMPUR") {
			options += "<option value='DEWAN BANDARAYA KUALA LUMPUR'>DEWAN BANDARAYA KUALA LUMPUR</option>";
		} else if(state == "SELANGOR") {
			options += "<option value='MAJLIS BANDARAYA SHAH ALAM'>MAJLIS BANDARAYA SHAH ALAM</option>"
			   + "<option value='MAJLIS BANDARAYA PETALING JAYA'>MAJLIS BANDARAYA PETALING JAYA</option>"
			   + "<option value='MAJLIS PERBANDARAN AMPANG JAYA'>MAJLIS PERBANDARAN AMPANG JAYA</option>"
			   + "<option value='MAJLIS PERBANDARAN KAJANG'>MAJLIS PERBANDARAN KAJANG</option>"
			   + "<option value='MAJLIS PERBANDARAN KLANG'>MAJLIS PERBANDARAN KLANG</option>"
			   + "<option value='MAJLIS PERBANDARAN SELAYANG'>MAJLIS PERBANDARAN SELAYANG</option>"
			   + "<option value='MAJLIS PERBANDARAN SEPANG'>MAJLIS PERBANDARAN SEPANG</option>"
			   + "<option value='MAJLIS PERBANDARAN SUBANG JAYA'>MAJLIS PERBANDARAN SUBANG JAYA</option>"
			   + "<option value='MAJLIS DAERAH HULU SELANGOR'>MAJLIS DAERAH HULU SELANGOR</option>"
			   + "<option value='MAJLIS DAERAH KUALA LANGAT'>MAJLIS DAERAH KUALA LANGAT</option>"
			   + "<option value='MAJLIS DAERAH KUALA SELANGOR'>MAJLIS DAERAH KUALA SELANGOR</option>"
			   + "<option value='MAJLIS DAERAH SABAK BERNAM'>MAJLIS DAERAH SABAK BERNAM</option>";
		} else if(state == "KEDAH") {
			options += "<option value='MAJLIS BANDARAYA ALOR SETAR'>MAJLIS BANDARAYA ALOR SETAR</option>"
			   + "<option value='MAJLIS PERBANDARAN KULIM'>MAJLIS PERBANDARAN KULIM</option>"
			   + "<option value='MAJLIS PERBANDARAN LANGKAWI'>MAJLIS PERBANDARAN LANGKAWI</option>"
			   + "<option value='MAJLIS PERBANDARAN SUNGAI PETANI'>MAJLIS PERBANDARAN SUNGAI PETANI</option>"
			   + "<option value='MAJLIS DAERAH BALING'>MAJLIS DAERAH BALING</option>"
			   + "<option value='MAJLIS DAERAH BANDAR BAHARU'>MAJLIS DAERAH BANDAR BAHARU</option>"
			   + "<option value='MAJLIS DAERAH KUBANG PASU'>MAJLIS DAERAH KUBANG PASU</option>"
			   + "<option value='MAJLIS DAERAH PADANG TERAP'>MAJLIS DAERAH PADANG TERAP</option>"
			   + "<option value='MAJLIS DAERAH PENDANG'>MAJLIS DAERAH PENDANG</option>"
			   + "<option value='MAJLIS DAERAH SIK'>MAJLIS DAERAH SIK</option>"
			   + "<option value='MAJLIS DAERAH YAN'>MAJLIS DAERAH YAN</option>";
		} else if(state == "PERLIS") {
			options += "<option value='MAJLIS PERBANDARAN KANGAR'>MAJLIS PERBANDARAN KANGAR</option>";
		} else if(state == "PULAU PINANG") {
			options += "<option value='MAJLIS PERBANDARAN PULAU PINANG'>MAJLIS PERBANDARAN PULAU PINANG</option>"
			   + "<option value='MAJLIS PERBANDARAN SEBERANG PERAI'>MAJLIS PERBANDARAN SEBERANG PERAI</option>";
		} else if(state == "PERAK") {
			options += "<option value='MAJLIS BANDARAYA IPOH'>MAJLIS BANDARAYA IPOH</option>"
				   + "<option value='MAJLIS PERBANDARAN MANJUNG'>MAJLIS PERBANDARAN MANJUNG</option>"
				   + "<option value='MAJLIS PERBANDARAN KUALA KANGSAR'>MAJLIS PERBANDARAN KUALA KANGSAR</option>"
				   + "<option value='MAJLIS PERBANDARAN TAIPING'>MAJLIS PERBANDARAN TAIPING</option>"
				   + "<option value='MAJLIS PERBANDARAN TELUK INTAN'>MAJLIS PERBANDARAN TELUK INTAN</option>"
				   + "<option value='MAJLIS DAERAH KAMPAR'>MAJLIS DAERAH KAMPAR</option>"
				   + "<option value='MAJLIS DAERAH GRIK'>MAJLIS DAERAH GRIK</option>"
				   + "<option value='MAJLIS DAERAH KERIAN'>MAJLIS DAERAH KERIAN</option>"				   
				   + "<option value='MAJLIS DAERAH BATU GAJAH'>MAJLIS DAERAH BATU GAJAH</option>"
				   + "<option value='MAJLIS DAERAH LENGGONG'>MAJLIS DAERAH LENGGONG</option>"
				   + "<option value='MAJLIS DAERAH PENGKALAN HULU'>MAJLIS DAERAH PENGKALAN HULU</option>"
				   + "<option value='MAJLIS DAERAH PERAK TENGAH'>MAJLIS DAERAH PERAK TENGAH</option>"
				   + "<option value='MAJLIS DAERAH SELAMA'>MAJLIS DAERAH SELAMA</option>"
				   + "<option value='MAJLIS DAERAH TANJUNG MALIM'>MAJLIS DAERAH TANJUNG MALIM</option>"
				   + "<option value='MAJLIS DAERAH TAPAH'>MAJLIS DAERAH TAPAH</option>";
		} else if(state == "NEGERI SEMBILAN") {
			options += "<option value='MAJLIS PERBANDARAN SEREMBAN'>MAJLIS PERBANDARAN SEREMBAN</option>"
				   + "<option value='MAJLIS PERBANDARAN PORT DICKSON'>MAJLIS PERBANDARAN PORT DICKSON</option>"				   
				   + "<option value='MAJLIS PERBANDARAN NILAI'>MAJLIS PERBANDARAN NILAI</option>"
				   + "<option value='MAJLIS DAERAH KUALA PILAH'>MAJLIS DAERAH KUALA PILAH</option>"
				   + "<option value='MAJLIS DAERAH JEMPOL'>MAJLIS DAERAH JEMPOL</option>"
				   + "<option value='MAJLIS DAERAH JELEBU'>MAJLIS DAERAH JELEBU</option>"
				   + "<option value='MAJLIS DAERAH REMBAU'>MAJLIS DAERAH REMBAU</option>"
				   + "<option value='MAJLIS DAERAH TAMPIN'>MAJLIS DAERAH TAMPIN</option>";
		} else if(state == "MELAKA") {
			options += "<option value='MAJLIS BANDARAYA MELAKA'>MAJLIS BANDARAYA MELAKA</option>"
				   + "<option value='MAJLIS PERBANDARAN HANG TUAH'>MAJLIS PERBANDARAN HANG TUAH</option>"
				   + "<option value='MAJLIS PERBANDARAN ALOR GAJAH'>MAJLIS PERBANDARAN ALOR GAJAH</option>"				   
				   + "<option value='MAJLIS PERBANDARAN JASIN'>MAJLIS PERBANDARAN JASIN</option>";
		} else if(state == "JOHOR") {
			options += "<option value='MAJLIS BANDARAYA JOHOR BAHRU'>MAJLIS BANDARAYA JOHOR BAHRU</option>"
				   + "<option value='MAJLIS PERBANDARAN JOHOR BAHRU TENGAH'>MAJLIS PERBANDARAN JOHOR BAHRU TENGAH</option>"				   
				   + "<option value='MAJLIS PERBANDARAN KLUANG'>MAJLIS PERBANDARAN KLUANG</option>"
				   + "<option value='MAJLIS PERBANDARAN KULAI'>MAJLIS PERBANDARAN KULAI</option>"
				   + "<option value='MAJLIS PERBANDARAN MUAR'>MAJLIS PERBANDARAN MUAR</option>"
				   + "<option value='MAJLIS PERBANDARAN PASIR GUDANG'>MAJLIS PERBANDARAN PASIR GUDANG</option>"
				   + "<option value='MAJLIS DAERAH KOTA TINGGI'>MAJLIS DAERAH KOTA TINGGI</option>"
				   + "<option value='MAJLIS DAERAH LABIS'>MAJLIS DAERAH LABIS</option>"
				   + "<option value='MAJLIS DAERAH MERSING'>MAJLIS DAERAH MERSING</option>"
				   + "<option value='MAJLIS DAERAH PONTIAN'>MAJLIS DAERAH PONTIAN</option>"				   
				   + "<option value='MAJLIS DAERAH SEGAMAT'>MAJLIS DAERAH SEGAMAT</option>"
				   + "<option value='MAJLIS DAERAH SIMPANG RENGGAM'>MAJLIS DAERAH SIMPANG RENGGAM</option>"
				   + "<option value='MAJLIS DAERAH TANGKAK'>MAJLIS DAERAH TANGKAK</option>"
				   + "<option value='MAJLIS DAERAH YONG PENG'>MAJLIS DAERAH YONG PENG</option>"
				   + "<option value='MAJLIS DAERAH BATU PAHAT'>MAJLIS DAERAH BATU PAHAT</option>"
				   + "<option value='LEMBAGA KEMAJUAN JOHOR TENGGARA'>LEMBAGA KEMAJUAN JOHOR TENGGARA</option>";
		} else if(state == "TERENGGANU") {
			options += "<option value='MAJLIS BANDARAYA KUALA TERENGGANU'>MAJLIS BANDARAYA KUALA TERENGGANU</option>"
				   + "<option value='MAJLIS PERBANDARAN KEMAMAN'>MAJLIS PERBANDARAN KEMAMAN</option>"				   
				   + "<option value='MAJLIS PERBANDARAN DUNGUN'>MAJLIS PERBANDARAN DUNGUN</option>"
				   + "<option value='MAJLIS DAERAH BESUT'>MAJLIS DAERAH BESUT</option>"
				   + "<option value='MAJLIS DAERAH MARANG'>MAJLIS DAERAH MARANG</option>"
				   + "<option value='MAJLIS DAERAH SETIU'>MAJLIS DAERAH SETIU</option>"
				   + "<option value='MAJLIS DAERAH HULU TERENGGANU'>MAJLIS DAERAH HULU TERENGGANU</option>";
		} else if(state == "PAHANG") {
			options += "<option value='MAJLIS PERBANDARAN KUANTAN'>MAJLIS PERBANDARAN KUANTAN</option>"
				   + "<option value='MAJLIS PERBANDARAN TEMERLOH'>MAJLIS PERBANDARAN TEMERLOH</option>"
				   + "<option value='MAJLIS PERBANDARAN BENTONG'>MAJLIS PERBANDARAN BENTONG</option>"				   
				   + "<option value='MAJLIS DAERAH CAMERON HIGHLANDS'>MAJLIS DAERAH CAMERON HIGHLANDS</option>"
				   + "<option value='MAJLIS DAERAH JERANTUT'>MAJLIS DAERAH JERANTUT</option>"
				   + "<option value='MAJLIS DAERAH LIPIS'>MAJLIS DAERAH LIPIS</option>"
				   + "<option value='MAJLIS DAERAH MARAN'>MAJLIS DAERAH MARAN</option>"
				   + "<option value='MAJLIS DAERAH PEKAN'>MAJLIS DAERAH PEKAN</option>"
				   + "<option value='MAJLIS DAERAH RAUB'>MAJLIS DAERAH RAUB</option>"
				   + "<option value='MAJLIS DAERAH ROMPIN'>MAJLIS DAERAH ROMPIN</option>"
				   + "<option value='MAJLIS DAERAH BERA'>MAJLIS DAERAH BERA</option>"
				   + "<option value='LEMBAGA KEMAJUAN TIOMAN'>LEMBAGA KEMAJUAN TIOMAN</option>";
		} else if(state == "KELANTAN") {
			options += "<option value='MAJLIS PERBANDARAN KOTA BHARU'>MAJLIS PERBANDARAN KOTA BHARU</option>"
				   + "<option value='MAJLIS DAERAH BACHOK'>MAJLIS DAERAH BACHOK</option>"
				   + "<option value='MAJLIS DAERAH GUA MUSANG'>MAJLIS DAERAH GUA MUSANG</option>"
				   + "<option value='MAJLIS DAERAH KETEREH'>MAJLIS DAERAH KETEREH</option>"
				   + "<option value='MAJLIS DAERAH DABONG'>MAJLIS DAERAH DABONG</option>"
				   + "<option value='MAJLIS DAERAH KUALA KRAI'>MAJLIS DAERAH KUALA KRAI</option>"
				   + "<option value='MAJLIS DAERAH MACHANG'>MAJLIS DAERAH MACHANG</option>"
				   + "<option value='MAJLIS DAERAH PASIR MAS'>MAJLIS DAERAH PASIR MAS</option>"
				   + "<option value='MAJLIS DAERAH PASIR PUTEH'>MAJLIS DAERAH PASIR PUTEH</option>"
				   + "<option value='MAJLIS DAERAH TANAH MERAH'>MAJLIS DAERAH TANAH MERAH</option>"
				   + "<option value='MAJLIS DAERAH TUMPAT'>MAJLIS DAERAH TUMPAT</option>"
				   + "<option value='MAJLIS DAERAH JELI'>MAJLIS DAERAH JELI</option>";
		} else if(state == "SABAH") {
			options += "<option value='DEWAN BANDARAYA KOTA KINABALU'>DEWAN BANDARAYA KOTA KINABALU</option>"
				   + "<option value='LEMBAGA BANDARAN KUDAT'>LEMBAGA BANDARAN KUDAT</option>"
				   + "<option value='MAJLIS PERBANDARAN SANDAKAN'>MAJLIS PERBANDARAN SANDAKAN</option>"
				   + "<option value='MAJLIS PERBANDARAN TAWAU'>MAJLIS PERBANDARAN TAWAU</option>"
				   + "<option value='MAJLIS DAERAH BEAUFORT'>MAJLIS DAERAH BEAUFORT</option>"
				   + "<option value='MAJLIS DAERAH BELURAN'>MAJLIS DAERAH BELURAN</option>"
				   + "<option value='MAJLIS DAERAH KENINGAU'>MAJLIS DAERAH KENINGAU</option>"
				   + "<option value='MAJLIS DAERAH KINABATANGAN'>MAJLIS DAERAH KINABATANGAN</option>"
				   + "<option value='MAJLIS DAERAH KOTA BELUD'>MAJLIS DAERAH KOTA BELUD</option>"
				   + "<option value='MAJLIS DAERAH KOTA MARUDU'>MAJLIS DAERAH KOTA MARUDU</option>"
				   + "<option value='MAJLIS DAERAH KUALA PENYU'>MAJLIS DAERAH KUALA PENYU</option>"
				   + "<option value='MAJLIS DAERAH KUNAK'>MAJLIS DAERAH KUNAK</option>"
				   + "<option value='MAJLIS DAERAH LAHAD DATU'>MAJLIS DAERAH LAHAD DATU</option>"
				   + "<option value='MAJLIS DAERAH NABAWAN'>MAJLIS DAERAH NABAWAN</option>"
				   + "<option value='MAJLIS DAERAH PAPAR'>MAJLIS DAERAH PAPAR</option>"
				   + "<option value='MAJLIS DAERAH PENAMPANG'>MAJLIS DAERAH PENAMPANG</option>"
				   + "<option value='MAJLIS DAERAH RANAU'>MAJLIS DAERAH RANAU</option>"
				   + "<option value='MAJLIS DAERAH SEMPORNA'>MAJLIS DAERAH SEMPORNA</option>"
				   + "<option value='MAJLIS DAERAH SIPITANG'>MAJLIS DAERAH SIPITANG</option>"
				   + "<option value='MAJLIS DAERAH TAMBUNAN'>MAJLIS DAERAH TAMBUNAN</option>"
				   + "<option value='MAJLIS DAERAH TENOM'>MAJLIS DAERAH TENOM</option>"
				   + "<option value='MAJLIS DAERAH TUARAN '>MAJLIS DAERAH TUARAN </option>"
				   + "<option value='MAJLIS DAERAH PITAS'>MAJLIS DAERAH PITAS</option>"
				   + "<option value='MAJLIS DAERAH PUTATAN'>MAJLIS DAERAH PUTATAN</option>";
		} else if(state == "SARAWAK") {
			options += "<option value='DEWAN BANDARAYA KUCHING'>DEWAN BANDARAYA KUCHING</option>"
				   + "<option value='DEWAN BANDARAYA KUCHING SELATAN'>DEWAN BANDARAYA KUCHING SELATAN</option>"
				   + "<option value='DEWAN BANDARAYAMIRI'>DEWAN BANDARAYAMIRI</option>"
				   + "<option value='MAJLIS PERBANDARAN PADAWAN'>MAJLIS PERBANDARAN PADAWAN</option>"
				   + "<option value='MAJLIS PERBANDARAN SIBU'>MAJLIS PERBANDARAN SIBU</option>"
				   + "<option value='MAJLIS PERBANDARAN BINTULU'>MAJLIS PERBANDARAN BINTULU</option>"
				   + "<option value='MAJLIS DAERAH BAU'>MAJLIS DAERAH BAU</option>"
				   + "<option value='MAJLIS DAERAH BETONG'>MAJLIS DAERAH BETONG</option>"
				   + "<option value='MAJLIS DAERAH DALAT-MUKAH'>MAJLIS DAERAH DALAT-MUKAH</option>"
				   + "<option value='MAJLIS DAERAH KANOWIT'>MAJLIS DAERAH KANOWIT</option>"
				   + "<option value='MAJLIS DAERAH KAPIT'>MAJLIS DAERAH KAPIT</option>"
				   + "<option value='MAJLIS DAERAH LAWAS'>MAJLIS DAERAH LAWAS</option>"
				   + "<option value='MAJLIS DAERAH SELANGAU'>MAJLIS DAERAH SELANGAU</option>"
				   + "<option value='MAJLIS DAERAH LUBOK'>MAJLIS DAERAH LUBOK</option>"
				   + "<option value='MAJLIS DAERAH ANTU'>MAJLIS DAERAH ANTU</option>"
				   + "<option value='MAJLIS DAERAH MERADONG-JULAU'>MAJLIS DAERAH MERADONG-JULAU</option>"
				   + "<option value='MAJLIS DAERAH LUNDU'>MAJLIS DAERAH LUNDU</option>"
				   + "<option value='MAJLIS DAERAH MARUDI'>MAJLIS DAERAH MARUDI</option>"
				   + "<option value='MAJLIS DAERAH MATU-DARO'>MAJLIS DAERAH MATU-DARO</option>"
				   + "<option value='MAJLIS DAERAH SAMARAHAN'>MAJLIS DAERAH SAMARAHAN</option>"
				   + "<option value='MAJLIS DAERAH SARATOK'>MAJLIS DAERAH SARATOK</option>"
				   + "<option value='MAJLIS DAERAH SARIKEI'>MAJLIS DAERAH SARIKEI</option>"
				   + "<option value='MAJLIS DAERAH SERIAN'>MAJLIS DAERAH SERIAN</option>"
				   + "<option value='MAJLIS DAERAH SIMUNJAN'>MAJLIS DAERAH SIMUNJAN</option>"
				   + "<option value='MAJLIS DAERAH SRI AMAN'>MAJLIS DAERAH SRI AMAN</option>"
				   + "<option value='MAJLIS DAERAH LIMBANG'>MAJLIS DAERAH LIMBANG</option>"
				   + "<option value='MAJLIS DAERAH SUBIS (BEKENU)'>MAJLIS DAERAH SUBIS (BEKENU)</option>";
		} else if(state == "WILAYAH PERSEKUTUAN PUTRAJAYA") {
			options += "<option value='LEMBAGA KEMAJUAN PUTRAJAYA'>LEMBAGA KEMAJUAN PUTRAJAYA</option>";
		} else if(state == "WILAYAH PERSEKUTUAN LABUAN") {
			options += "<option value='LEMBAGA KEMAJUAN LABUAN'>LEMBAGA KEMAJUAN LABUAN</option>";
		}
		
		$('select#issuer').html(options).val(issuer);

	},
	
	payment_info_reset : function(elmt) {
		if($(elmt).attr('data-type') == 'visa_master'){
			$('#visa_master_credit_maybank').val("000000000000");
			$('#visa_master_interbank_giro_service').val("012");
			$('#visa_master_interbank_giro_bank').val("002");
			$('#visa_master_interbank_giro_acc_no').val('');
			$('#visa_master_center_code').val("02700000");
			$('input[name="visa_master"]').prop('checked', false);
		} else if($(elmt).attr('data-type') == 'amex'){
			$('#amex_credit_maybank').val("000000000000");
			$('#amex_interbank_giro_service').val("0000000000000000000");
			$('#amex_interbank_giro_bank_code').val("02001");
			$('#amex_banker_cheque_bank_code').val("01001");
			$('#amex_payment_method').val("Individual Pay");
			$('#amex_payment_plan').val("102");
			$('#amex_branch_code').val("00000");
			$('input[name="amex"]').prop('checked', false);
		} else if($(elmt).attr('data-type') == 'union_pay') {
			$('input[name="union_pay"]').prop('checked', false);
		} else if($(elmt).attr('data-type') == 'ezy_pay') {
			$('#ezypay_center_code').val("27000000");
			$('#ezypay_branch_code').val("00000");
		} else if($(elmt).attr('data-type') == 'mbb_philippine') {
			$('#maybank_philippine_center_code').val("10100000");
			$('#maybank_philippine_branch_code').val("00000");
		} else if($(elmt).attr('data-type') == 'mbb_singapore') {
			$('#maybank_singapore_center_code').val("10200000");
			$('#maybank_singapore_branch_code').val("00000");
		}
	},
	
	statement_option_reset : function(elmt) {
		if($(elmt).attr('data-type') == 'visa_master'){
			$('#visa_2').val("");
			$('#visa_3').val("");
			$('input[name="visa_1"]').prop('checked', false);
		} else {
			$('#amex_2').val("");
			$('input[name="amex_1"]').prop('checked', false);
		}
		
	},

	onblur_format : function(item, len){
		var v = $(item).val();
		v = v.pad_left(len, '0');
		$(item).val(v);
	}
};